# module checkversion en python, avec le socket qui bloque c'est moche ><

import ns
import urllib
import string

def pcheck(msg):
	if msg['nbarg'] < 2:
		return 0

	tmp = msg['argu'].split(' ')
	page = urllib.urlopen("http://syndrome.sagwin.org/chkversion?mod=" + tmp[1])
	strpage = page.read()
	
	if strpage.find ("existe pas") != -1:
		ns.bot_send_privmsg (msg['dest'], "Module " + tmp[1] + " non reference")
		return 0
	
	debut = strpage.partition ("<body>")
	good = debut[2].partition ("</body>")
	ns.bot_send_privmsg (msg['dest'], "Version courante du module " + tmp[1] + " : " + good[0].strip())

	
ns.bot_add_cmd_handler("$pcheck", pcheck)
